class Output:
	type = "NA"
	def __init__(self):
		pass
	
class OutputVm(Output):
	k8055 		= None
	channel 		= None
	type 			= None
	aoEuMin 		= None
	aoEuMax 		= None
	aoRawMin 	= None
	aoRawMax 	= None
	
	def __init__(self,type,k8055instance,k8055channel):
		self.k8055 			= k8055instance
		self.channel 		= k8055channel
		self.type 			= type
		self.aoEuMin 		= 0
		self.aoEuMax 		= 100
		self.aoRawMin 		= 0
		self.aoRawMax 		= 255
	
	def set(self,value):
		if self.type.upcase()=="DO":
			if(value==1 or value==True):
				self.k8055.setDigitalChannel(self.channel)
			else:
				self.k8055.clearDigitalChannel(self.channel)
		elif self.type.upcase()=="AO":
			rangeEu 	= self.aoEuMax-self.aoEuMin
			rangeRaw = self.aoRawMax-self.aoRawMin
			outvalue	= int((float(value)/float(rangeEu))*float(rangeRaw))
			self.k8055.outputAnalogChannel(self.channel,outvalue)
			
		
